#include<stdio.h>

int main(int argc,char *argv[])
{
    if(argc==2)
    {
        printf("my_cp:missing destination file operand after '%s'\n",argv[1]);
        printf("Try 'cp --help' for more information.\n");
        return 0;
    }
    FILE *fpr,*fpw;
    fpr=fopen(argv[1],"r");
    if(fpr==NULL)
    {
        printf("open file %s failed!\n",argv[1]);
        return 0;
    }
    fpw=fopen(argv[2],"w");
    if(fpw==NULL)
    {
        printf("open file %s failed!\n",argv[2]);
        return 0;
    }
    int ch;
    while((ch=fgetc(fpr))!=EOF)
    {
        fputc(ch,fpw);
    }
    int flag=fclose(fpr);
    if(flag!=0)
    {
        printf("close file %s failed!\n",argv[1]);
        return 0;
    }
    flag=fclose(fpw);
    if(flag!=0)
    {
        printf("close file %s failed!\n",argv[2]);
        return 0;
    }
    return 0;
}
